import request from '@/utils/request'

/*
部门管理相关的API请求函数
*/
const api_name = '/admin/system/sysDept'

export default {

  /*
  获取部门列表
  */
  findNodes() {
    return request({
      url: `${api_name}/findNodes`,
      method: 'get'
    })
  },

  /*
  查询单个部门
  */
  findNode(id) {
    return request({
      url: `${api_name}/findNode/${id}`,
      method: 'get'
    })
  },

  /*
  删除
  */
  removeById(id) {
    return request({
      url: `${api_name}/remove/${id}`,
      method: 'delete'
    })
  },

  /*
  批量删除
  */
  batchRemove(ids) {
    return request({
      url: `${api_name}/batchRemove`,
      method: 'delete',
      data: ids
    })
  },

  /*
  保存
  */
  save(sysDept) {
    return request({
      url: `${api_name}/save`,
      method: 'post',
      data: sysDept
    })
  },

  /*
  更新
  */
  updateById(sysDept) {
    return request({
      url: `${api_name}/update`,
      method: 'put',
      data: sysDept
    })
  },

  findNodesById(id) {
    return request({
      url: `${api_name}/findNodes/${id}`,
      method: 'get'
    })
  },

  //根据用户id查询用户已分配的部门
  getDeptsByUserId(userId) {
    return request({
      url: `${api_name}/toAssign/${userId}`,
      method: 'get'
    })
  },

  //分配部门
  assignDepts(assginDeptVo) {
    return request({
      url: `${api_name}/doAssign`,
      method: 'post',
      data: assginDeptVo
    })
  },

  //修改状态
  updateStatus(id, status) {
    return request({
      url: `${api_name}/updateStatus/${id}/${status}`,
      method: 'put'
    })
  }
}
